<!--
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2023-11-07 21:17:01
 * @LastEditors: sueRimn
 * @LastEditTime: 2023-11-25 09:45:54
-->
<template>
    <view class='copyright'>
        <view class='text'>©出手鸭 v<text>{{ version }}</text>.{{envVersion}} Build</view>
        <view class='text'> </view>
        <view class='text' @click="handleClick">出手鸭 版权所有</view>
        <view class='text'>Copyright 2018-{{ year }} CHUSHOUYA All Right Reserved.</view>
    </view>
</template>
<script>
export default {
    props: {
        version: {
            type: String,
            default: ''
        },
        envVersion: {
            type: String,
            default: ''
        },
        year: {
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            clickCount: 0,
            clickTimer: null
        }
    },
    methods: {
        handleClick() {
            this.clickCount++;
            
            // 清除之前的定时器
            if (this.clickTimer) {
                clearTimeout(this.clickTimer);
            }
            
            // 如果连续点击10次，调用父组件的handleChangeEnv方法
            if (this.clickCount >= 5) {
                this.$emit('handleChangeEnv');
                this.clickCount = 0;
                return;
            }
            
            // 设置定时器，2秒后重置点击次数
            this.clickTimer = setTimeout(() => {
                this.clickCount = 0;
            }, 2000);
        }
    },
    beforeDestroy() {
        // 组件销毁前清除定时器
        if (this.clickTimer) {
            clearTimeout(this.clickTimer);
        }
    }
}


</script>
<style lang="scss">

.copyright {
    text-align: center;
    margin: 100rpx auto 0;

    .text {
        color: var(--hui-color-label);
        margin-top: 10rpx;
        font-size: var(--hui-font-size-28);
    }
}
</style>